package com.zbkj.common.response;

import cn.hutool.core.util.StrUtil;
import com.google.common.base.Joiner;
import com.zbkj.common.enums.FosterCycleTypeEnum;
import com.zbkj.common.model.coupon.Coupon;
import com.zbkj.common.model.member.CardVo;
import com.zbkj.common.model.merchant.MerchantAddress;
import com.zbkj.common.model.product.Product;
import com.zbkj.common.model.product.ProductAttr;
import com.zbkj.common.model.product.ProductGuarantee;
import com.zbkj.common.monitorchannel.vo.MonitorChannelMediaAddressVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;

/**
 * 移动端商品详情响应对象
 * +----------------------------------------------------------------------
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "ProductDetailResponse对象", description = "移动端商品详情响应对象")
public class ProductDetailResponse implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "产品属性")
    private List<ProductAttr> productAttr;

    @ApiModelProperty(value = "商品属性详情")
    private HashMap<String, ProductAttrValueResponse> productValue;

    @ApiModelProperty(value = "商品信息")
    private Product productInfo;

    @ApiModelProperty(value = "商户信息")
    private ProductMerchantResponse merchantInfo;

    @ApiModelProperty(value = "收藏标识")
    private Boolean userCollect;

    @ApiModelProperty(value = "保障服务")
    private List<ProductGuarantee> guaranteeList;

    @ApiModelProperty(value = "主商品ID，普通商品值为0")
    private Integer masterProductId = 0;

    @ApiModelProperty(value = "活动单次限购")
    private Integer oneQuota;

    @ApiModelProperty(value = "秒杀开始时间(时间戳)")
    private Long startTimeStamp = 0L;

    @ApiModelProperty(value = "秒杀结束时间(时间戳)")
    private Long endTimeStamp = 0L;

    @ApiModelProperty(value = "优惠券信息(商户)")
    private List<Coupon> couponList;

    @ApiModelProperty("监控流媒体地址")
    private List<MonitorChannelMediaAddressVo> monitorMediaAddressList;


    @ApiModelProperty("设备license列表")
    private List<String> license;

    @ApiModelProperty(value = "商品品类")
    private String productType;

    @ApiModelProperty(value = "商品品种")
    private String productVariety;

    @ApiModelProperty(value = "种苗单价")
    private BigDecimal seedlingPrice;

    @ApiModelProperty(value = "认养周期类型(天、周、月、季度、年)")
    private FosterCycleTypeEnum cycleType;

    @ApiModelProperty(value = "周期单价")
    private BigDecimal cyclePrice;

    @ApiModelProperty(value = "种苗寄送地址ID")
    private Integer addressId;

    @ApiModelProperty(value = "种苗寄送地址")
    private MerchantAddress address;
    @ApiModelProperty(value = "获取在商品详情展示的引流vip列表")
    private List<CardVo> cardVos;

    public Product getProductInfo() {
        return productInfo;
    }

    public void setProductInfo(Product productInfo) {

        //转成list
        if (StrUtil.isNotBlank(productInfo.getLicense())) {
            List<String> split = StrUtil.split(productInfo.getLicense(), ',');
            split.removeIf(o -> StrUtil.isBlank(o));
            this.license = split;
            productInfo.setLicense(Joiner.on(",").join(split));
        }
        this.productInfo = productInfo;
    }
}
